home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_1199 / 1709 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  1.3 KB

  1. From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
  2. Date: Fri, 15 Jul 94 10:32:37 +0200
  3. Message-Id: <9407150832.AA11599@issan.informatik.uni-dortmund.de>
  4. To: evanlang@uss.lonestar.org
  5. In-Reply-To: <m0qOUWr-0004q4C@uss.lonestar.org> (evanlang@uss.lonestar.org)
  6. Subject: Re: Alignment
  7.  
  8. evanlang@uss.lonestar.org (Evan Langlois) writes:
  9.  
  10. |> If I cast a const char * such as "MiNT" or "LIVE" to a long *, shouldn't
  11. |> the compiler store the string so that it is aligned to a long boundary?
  12. |> Otherwise, when trying to read the long at that address, it could be on
  13. |> an odd address, and the machine dies.
  14.  
  15. Casting a pointer to a pointer with more alignment restrictions is
  16. undefined in ANSI C, and you can never expect that this works.  The
  17. compiler is always allowed to align an object using the least
  18. restriction as possible, and for strings (that are char[]) this is
  19. byte alignment (for the m68k anyway).  It is impossible for the
  20. compiler to deduce that you are planning to access it via long *,
  21. since this could be hidden through many function calls.  Btw., on a
  22. 68020+ this will succeed nevertheless.
  23.  
  24. -- 
  25. +------------------------------------------------------------------------+
  26. Andreas Schwab                                      "And now for something
  27. schwab@ls5.informatik.uni-dortmund.de                completely different"
  28.